package com.bzchao.oauth;

import com.bzchao.oauth.bean.SysModule;
import com.bzchao.oauth.bean.SysRole;
import com.bzchao.oauth.bean.SysUser;
import com.bzchao.oauth.service.ModuleService;
import com.bzchao.oauth.service.RoleService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest// 指定启动类
public class StartTest {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private UserDetailsService userDetailsService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private ModuleService moduleService;

    @Test
    public void test() {
        String encode = passwordEncoder.encode("123456");
        boolean matches = passwordEncoder.matches("123456", "$2a$10$cjQA/eAnvs2cuxPQPrvNhue4D7Q4Nk2Dd1m4BclmDeG.BqV.ODnwK");
        System.out.println(encode);
        System.out.println(matches);
    }

    @Test
    public void test02() {
        List<SysRole> sysUsers = roleService.selectRoleByUserId("e0de22fe-2c50-4216-ad75-ed0494d2dc92");
        System.out.println(sysUsers.size());
    }

    @Test
    public void test03() {
        List<SysModule> sysModules = moduleService.selectModuleByRoleId("4028a1cd4ee2d9d6014ee2df4c6a0007");
        System.out.println(sysModules);
    }
}
